<?php

namespace App\Http\Models;

use App\Support\Data;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;


class Medical extends BaseModel
{
    use SoftDeletes;
    use HasDateTimeFormatter;
    protected $table = 'medical';
    public $timestamps = true;

    public $default_image = 'https://resources.gongshicloud.com/default/20220615174538-62a9aa425e8ad.png';


    protected $fillable = [
        'id',
        'act_id',
        'name',
        'height',
        'weight',
        'sex',
        'age',
        'source',
        'source_input',
        'bim',
        'bim_radio',
        'symptom',
        'symptom_input',
        'disease_code',
        'course_disease',
        'drink_alcohol',
        'drink_alcohol_quantity',
        'drink_alcohol_frequency',
        'smoking_history',
        'smoking_history_year',
        'smoking_history_quantity',
        'family_historyL',
        'past_historyL',
        'medical_history',
        'allergy',
        'allergy_input',
        'check',
        'check_true',
        'check_true_laboratory',
        'check_true_image',
        'check_true_pathology',
        'check_true_other',
        'check_false',
        'check_false_input',
        'treatment',
        'treatment_plan_date',
        'treatment_specific',
        'treatment_effect',
        'treatment_return_visit',
        'treatment_untreated',
        'digestive_diseases',
        'digestive_diseases_laboratory',
        'digestive_diseases_image',
        'digestive_diseases_pathology',
        'digestive_diseases_other',
        'helicobacter_pylori',
        'comorbidities',
        'comorbidities_anxiety',
        'comorbidities_depression',
        'comorbidities_other',
        'disease_identify',
        'disease_identify_true',
        'disease_identify_false',
        'disease_diagnosis',
        'disease_diagnosis_input',
        'disease_classification',
        'disease_comorbidities',
        'disease_comorbidities_input',
        'treatment_plan',
        'treatment_date',
        'treatment_mg',
        'treatment_bag',
        'treatment_situation',
        'treatment_situation_input',
        'treatment_dose',
        'treatment_dose_input',
        'gastritis_clinical',
        'gastritis_laboratory',
        'gastritis_curativeeffect',
        'gastritis_complications',
        'ulcer_clinical',
        'ulcer_evaluation',
        'ulcer_hp',
        'ulcer_complications',
        'dyspepsia_evaluation',
        'dyspepsia_evaluate',
        'dyspepsia_quality',
        'ulcer_other',
        'otherdiseases_clinical',
        'otherdiseases_other',
        'adversereaction',
        'adversereaction_group',
        'adversereaction_group_input',
        'adversereaction_date',
        'adversereaction_immediately',
        'adversereaction_time_input',
        'adversereaction_degree',
        'adversereaction_related',
        'adversereaction_strategy',
        'user_id',
        'status',

        'tcm_syndrome_type',

        'pre_degree_pain_chest_ribs',
        'pre_degree_epigastric_full',
        'pre_degree_be_upset',
        'pre_degree_eructation_frequent',
        'pre_degree_mild_breathing',

        'pre_frequency_pain_chest_ribs',
        'pre_frequency_epigastric_full',
        'pre_frequency_be_upset',
        'pre_frequency_eructation_frequent',
        'pre_frequency_mild_breathing',

        'post_degree_pain_chest_ribs',
        'post_degree_epigastric_full',
        'post_degree_be_upset',
        'post_degree_eructation_frequent',
        'post_degree_mild_breathing',

        'post_frequency_pain_chest_ribs',
        'post_frequency_epigastric_full',
        'post_frequency_be_upset',
        'post_frequency_eructation_frequent',
        'post_frequency_mild_breathing',
    ];

    protected $hidden = [
        // 'status',
        'deleted_at'
        // 'examine_time'

    ];

    protected $casts = [
        'created_at' => 'datetime:Y-m-d',
        'updated_at' => 'datetime:Y-m-d',
        // 'invoice_img' => array,
        // 'discharge_summary_img' => array,
    ];


    public function getMedicalDataAttribute($value)
    {
        if (empty($value)) {
            return [];
        }

        $arr = [];
        $url_arr = explode(',', $value);

        foreach ($url_arr as $key => $val) {

            if (!empty($val)) {
                $url = parse_url($val);
                $fileName = basename($url['path']);
                $w_param = pathinfo($val);
                $data['name'] = $fileName;
                $data['url'] = $val;
                $data['ext'] = empty($w_param['extension']) ? '' : $w_param['extension'];
                array_push($arr, $data);
            }
        }
        return $arr;
    }

    public function getSourceTextAttribute($value)
    {
        $source = Data::getMedicalSource();
        return isset($source[$value]) && !empty($source[$value]) ? $source[$value] : '';
    }

    public function getSexTextAttribute($value)
    {
        $sex = Data::getSex();
        return isset($sex[$value]) && !empty($sex[$value]) ? $sex[$value] : '';
    }

    public function getSymptomAttribute($value)
    {
        if (isset($value) && !empty($value)) {
            return explode(',', $value);
        } else {
            return [];
        }
    }
    // check_true
    public function getCheckTrueAttribute($value)
    {
        if (isset($value) && !empty($value)) {
            return explode(',', $value);
        } else {
            return [];
        }
    }

    public function getCheckFalseAttribute($value)
    {
        if (isset($value) && !empty($value)) {
            return explode(',', $value);
        } else {
            return [];
        }
    }
    // digestive_diseases
    public function getDigestiveDiseasesAttribute($value)
    {
        if (isset($value) && !empty($value)) {
            return explode(',', $value);
        } else {
            return [];
        }
    }
    // comorbidities
    public function getComorbiditiesAttribute($value)
    {
        if (isset($value) && !empty($value)) {
            return explode(',', $value);
        } else {
            return [];
        }
    }
    // disease_diagnosis
    public function getDiseaseDiagnosisAttribute($value)
    {
        if (isset($value) && !empty($value)) {
            return explode(',', $value);
        } else {
            return [];
        }
    }
    // adversereaction_group
    public function getAdversereactionGroupAttribute($value)
    {
        if (isset($value) && !empty($value)) {
            return explode(',', $value);
        } else {
            return [];
        }
    }

    // tcm_syndrome_type
    public function getTcmSyndromeTypeAttribute($value)
    {
        if (isset($value) && !empty($value)) {
            return explode(',', $value);
        } else {
            return [];
        }
    }
    /**
     * 我的病例
     *
     * @Author hechengwei
     * @email chichiooo@sina.com
     * @DateTime 2022-03-07
     * @param [int] $page
     * @param [int] $limit
     * @param [array] $where
     * @param [array] $field
     * @return mixed
     */
    public function getMedicalList($page, $limit, $where = [], $field = ['*'])
    {

        $where = function ($query) use ($where) {



            $query->where('status', 1);

            if (isset($where['name']) && $where['name'] != '') {
                $query->where('title', 'like', '%' . $where['name'] . '%');
            }

            if (isset($where['user_id']) && $where['user_id'] != '') {
                $query->where('user_id', $where['user_id']);
            }
        };
        return $this->paginate($page, $limit, $where, $field, 'desc', 'page', '');
    }


    /**
     * 我的病例
     *
     * @Author hechengwei
     * @email chichiooo@sina.com
     * @DateTime 2022-03-07
     * @param [int] $page
     * @param [int] $limit
     * @param [array] $where
     * @param [array] $field
     * @return mixed
     */
    public function getMedicalListByUser($page, $limit, $where = [], $field = ['*'])
    {

        $where = function ($query) use ($where) {

            // $query->where('status', 1);

            if (isset($where['status']) && $where['status'] != '') {
                $query->where('status', $where['status']);
            }

            if (isset($where['user_id']) && $where['user_id'] != '') {
                $query->where('user_id', $where['user_id']);
            }
        };
        return $this->paginate($page, $limit, $where, $field, 'desc', 'page',  '');
    }

    /**
     * 我的病例
     *
     * @Author hechengwei
     * @email chichiooo@sina.com
     * @DateTime 2024-02-02
     * @param [array] $where
     * @param [array] $field
     * @return mixed
     */
    public function getListByUser($where = [], $field = ['*'])
    {

        $where = function ($query) use ($where) {

            if (isset($where['user_id']) && $where['user_id'] != '') {
                $query->where('user_id', $where['user_id']);
            }
        };
        return $this->where($where)->select($field)->get();
    }


    /**
     * 病例库修改
     *
     * @Author hechengwei
     * @email chichiooo@sina.com
     * @DateTime 2022-05-11
     * @param array $payload
     * @param int $id
     * @return void
     */
    public static function updateMedical($payload, $id)
    {
        Log::info('病例提交数据：' . json_encode($payload));
        $model = self::find($id);
        $model->name = isset($payload['name']) && !empty($payload['name']) ? $payload['name'] : '';
        $model->height = isset($payload['height']) && !empty($payload['height']) ? $payload['height'] : '';
        $model->weight = isset($payload['weight']) && !empty($payload['weight']) ? $payload['weight'] : '';
        $model->sex = isset($payload['sex']) && !empty($payload['sex']) ? $payload['sex'] : '';
        $model->age = isset($payload['age']) && !empty($payload['age']) ? $payload['age'] : '';
        $model->source = isset($payload['source']) && !empty($payload['source']) ? $payload['source'] : '';
        $model->source_input = isset($payload['source_input']) && !empty($payload['source_input']) ? $payload['source_input'] : '';
        $model->bim = isset($payload['bim']) && !empty($payload['bim']) ? $payload['bim'] : '';
        $model->bim_radio = isset($payload['bim_radio']) && !empty($payload['bim_radio']) ? $payload['bim_radio'] : '';
        $model->symptom = isset($payload['symptom']) && !empty($payload['symptom']) ? $payload['symptom'] : '';
        $model->symptom_input = isset($payload['symptom_input']) && !empty($payload['symptom_input']) ? $payload['symptom_input'] : '';
        $model->disease_code = isset($payload['disease_code']) && !empty($payload['disease_code']) ? $payload['disease_code'] : '';
        $model->course_disease = isset($payload['course_disease']) && !empty($payload['course_disease']) ? $payload['course_disease'] : '';
        $model->drink_alcohol = isset($payload['drink_alcohol']) && !empty($payload['drink_alcohol']) ? $payload['drink_alcohol'] : '';
        $model->drink_alcohol_quantity = isset($payload['drink_alcohol_quantity']) && !empty($payload['drink_alcohol_quantity']) ? $payload['drink_alcohol_quantity'] : '';
        $model->drink_alcohol_frequency = isset($payload['drink_alcohol_frequency']) && !empty($payload['drink_alcohol_frequency']) ? $payload['drink_alcohol_frequency'] : '';
        $model->smoking_history = isset($payload['smoking_history']) && !empty($payload['smoking_history']) ? $payload['smoking_history'] : '';
        $model->smoking_history_year = isset($payload['smoking_history_year']) && !empty($payload['smoking_history_year']) ? $payload['smoking_history_year'] : '';
        $model->smoking_history_quantity = isset($payload['smoking_history_quantity']) && !empty($payload['smoking_history_quantity']) ? $payload['smoking_history_quantity'] : '';
        $model->family_historyL = isset($payload['family_historyL']) && !empty($payload['family_historyL']) ? $payload['family_historyL'] : '';
        $model->past_historyL = isset($payload['past_historyL']) && !empty($payload['past_historyL']) ? $payload['past_historyL'] : '';
        $model->medical_history = isset($payload['medical_history']) && !empty($payload['medical_history']) ? $payload['medical_history'] : '';
        $model->allergy = isset($payload['allergy']) && !empty($payload['allergy']) ? $payload['allergy'] : '';
        $model->allergy_input = isset($payload['allergy_input']) && !empty($payload['allergy_input']) ? $payload['allergy_input'] : '';
        $model->check = isset($payload['check']) && !empty($payload['check']) ? $payload['check'] : '';
        $model->check_true = isset($payload['check_true']) && !empty($payload['check_true']) ? $payload['check_true'] : '';
        $model->check_true_laboratory = isset($payload['check_true_laboratory']) && !empty($payload['check_true_laboratory']) ? $payload['check_true_laboratory'] : '';
        $model->check_true_image = isset($payload['check_true_image']) && !empty($payload['check_true_image']) ? $payload['check_true_image'] : '';
        $model->check_true_pathology = isset($payload['check_true_pathology']) && !empty($payload['check_true_pathology']) ? $payload['check_true_pathology'] : '';
        $model->check_true_other = isset($payload['check_true_other']) && !empty($payload['check_true_other']) ? $payload['check_true_other'] : '';
        $model->check_false = isset($payload['check_false']) && !empty($payload['check_false']) ? $payload['check_false'] : '';
        $model->check_false_input = isset($payload['check_false_input']) && !empty($payload['check_false_input']) ? $payload['check_false_input'] : '';
        $model->treatment = isset($payload['treatment']) && !empty($payload['treatment']) ? $payload['treatment'] : '';
        $model->treatment_plan_date = isset($payload['treatment_plan_date']) && !empty($payload['treatment_plan_date']) ? $payload['treatment_plan_date'] : '';
        $model->treatment_specific = isset($payload['treatment_specific']) && !empty($payload['treatment_specific']) ? $payload['treatment_specific'] : '';
        $model->treatment_effect = isset($payload['treatment_effect']) && !empty($payload['treatment_effect']) ? $payload['treatment_effect'] : '';
        $model->treatment_return_visit = isset($payload['treatment_return_visit']) && !empty($payload['treatment_return_visit']) ? $payload['treatment_return_visit'] : '';
        $model->treatment_untreated = isset($payload['treatment_untreated']) && !empty($payload['treatment_untreated']) ? $payload['treatment_untreated'] : '';
        $model->digestive_diseases = isset($payload['digestive_diseases']) && !empty($payload['digestive_diseases']) ? $payload['digestive_diseases'] : '';
        $model->digestive_diseases_laboratory = isset($payload['digestive_diseases_laboratory']) && !empty($payload['digestive_diseases_laboratory']) ? $payload['digestive_diseases_laboratory'] : '';
        $model->digestive_diseases_image = isset($payload['digestive_diseases_image']) && !empty($payload['digestive_diseases_image']) ? $payload['digestive_diseases_image'] : '';

        $model->digestive_diseases_pathology = isset($payload['digestive_diseases_pathology']) && !empty($payload['digestive_diseases_pathology']) ? $payload['digestive_diseases_pathology'] : '';
        $model->digestive_diseases_other = isset($payload['digestive_diseases_other']) && !empty($payload['digestive_diseases_other']) ? $payload['digestive_diseases_other'] : '';
        $model->helicobacter_pylori = isset($payload['helicobacter_pylori']) && !empty($payload['helicobacter_pylori']) ? $payload['helicobacter_pylori'] : '';
        $model->comorbidities = isset($payload['comorbidities']) && !empty($payload['comorbidities']) ? $payload['comorbidities'] : '';
        $model->comorbidities_anxiety = isset($payload['comorbidities_anxiety']) && !empty($payload['comorbidities_anxiety']) ? $payload['comorbidities_anxiety'] : '';
        $model->comorbidities_depression = isset($payload['comorbidities_depression']) && !empty($payload['comorbidities_depression']) ? $payload['comorbidities_depression'] : '';
        $model->comorbidities_other = isset($payload['comorbidities_other']) && !empty($payload['comorbidities_other']) ? $payload['comorbidities_other'] : '';
        $model->disease_identify = isset($payload['disease_identify']) && !empty($payload['disease_identify']) ? $payload['disease_identify'] : '';
        $model->disease_identify_true = isset($payload['disease_identify_true']) && !empty($payload['disease_identify_true']) ? $payload['disease_identify_true'] : '';
        $model->disease_identify_false = isset($payload['disease_identify_false']) && !empty($payload['disease_identify_false']) ? $payload['disease_identify_false'] : '';
        $model->disease_diagnosis = isset($payload['disease_diagnosis']) && !empty($payload['disease_diagnosis']) ? $payload['disease_diagnosis'] : '';
        $model->disease_diagnosis_input = isset($payload['disease_diagnosis_input']) && !empty($payload['disease_diagnosis_input']) ? $payload['disease_diagnosis_input'] : '';
        $model->disease_classification = isset($payload['disease_classification']) && !empty($payload['disease_classification']) ? $payload['disease_classification'] : '';
        $model->disease_comorbidities = isset($payload['disease_comorbidities']) && !empty($payload['disease_comorbidities']) ? $payload['disease_comorbidities'] : '';
        $model->disease_comorbidities_input = isset($payload['disease_comorbidities_input']) && !empty($payload['disease_comorbidities_input']) ? $payload['disease_comorbidities_input'] : '';
        $model->treatment_plan = isset($payload['treatment_plan']) && !empty($payload['treatment_plan']) ? $payload['treatment_plan'] : '';
        $model->treatment_date = isset($payload['treatment_date']) && !empty($payload['treatment_date']) ? $payload['treatment_date'] : '';

        $model->treatment_mg = isset($payload['treatment_mg']) && !empty($payload['treatment_mg']) ? $payload['treatment_mg'] : '';
        $model->treatment_bag = isset($payload['treatment_bag']) && !empty($payload['treatment_bag']) ? $payload['treatment_bag'] : '';
        $model->treatment_situation = isset($payload['treatment_situation']) && !empty($payload['treatment_situation']) ? $payload['treatment_situation'] : '';
        $model->treatment_situation_input = isset($payload['treatment_situation_input']) && !empty($payload['treatment_situation_input']) ? $payload['treatment_situation_input'] : '';
        $model->treatment_dose = isset($payload['treatment_dose']) && !empty($payload['treatment_dose']) ? $payload['treatment_dose'] : '';
        $model->treatment_dose_input = isset($payload['treatment_dose_input']) && !empty($payload['treatment_dose_input']) ? $payload['treatment_dose_input'] : '';
        $model->gastritis_clinical = isset($payload['gastritis_clinical']) && !empty($payload['gastritis_clinical']) ? $payload['gastritis_clinical'] : '';
        $model->gastritis_laboratory = isset($payload['gastritis_laboratory']) && !empty($payload['gastritis_laboratory']) ? $payload['gastritis_laboratory'] : '';
        $model->gastritis_curativeeffect = isset($payload['gastritis_curativeeffect']) && !empty($payload['gastritis_curativeeffect']) ? $payload['gastritis_curativeeffect'] : '';
        $model->gastritis_complications = isset($payload['gastritis_complications']) && !empty($payload['gastritis_complications']) ? $payload['gastritis_complications'] : '';
        $model->ulcer_clinical = isset($payload['ulcer_clinical']) && !empty($payload['ulcer_clinical']) ? $payload['ulcer_clinical'] : '';
        $model->ulcer_evaluation = isset($payload['ulcer_evaluation']) && !empty($payload['ulcer_evaluation']) ? $payload['ulcer_evaluation'] : '';
        $model->ulcer_hp = isset($payload['ulcer_hp']) && !empty($payload['ulcer_hp']) ? $payload['ulcer_hp'] : '';
        $model->ulcer_complications = isset($payload['ulcer_complications']) && !empty($payload['ulcer_complications']) ? $payload['ulcer_complications'] : '';
        $model->dyspepsia_evaluation = isset($payload['dyspepsia_evaluation']) && !empty($payload['dyspepsia_evaluation']) ? $payload['dyspepsia_evaluation'] : '';
        $model->dyspepsia_evaluate = isset($payload['dyspepsia_evaluate']) && !empty($payload['dyspepsia_evaluate']) ? $payload['dyspepsia_evaluate'] : '';
        $model->dyspepsia_quality = isset($payload['dyspepsia_quality']) && !empty($payload['dyspepsia_quality']) ? $payload['dyspepsia_quality'] : '';
        $model->ulcer_other = isset($payload['ulcer_other']) && !empty($payload['ulcer_other']) ? $payload['ulcer_other'] : '';
        $model->otherdiseases_clinical = isset($payload['otherdiseases_clinical']) && !empty($payload['otherdiseases_clinical']) ? $payload['otherdiseases_clinical'] : '';
        $model->otherdiseases_other = isset($payload['otherdiseases_other']) && !empty($payload['otherdiseases_other']) ? $payload['otherdiseases_other'] : '';
        $model->adversereaction = isset($payload['adversereaction']) && !empty($payload['adversereaction']) ? $payload['adversereaction'] : '';
        $model->adversereaction_group = isset($payload['adversereaction_group']) && !empty($payload['adversereaction_group']) ? $payload['adversereaction_group'] : '';
        $model->adversereaction_group_input = isset($payload['adversereaction_group_input']) && !empty($payload['adversereaction_group_input']) ? $payload['adversereaction_group_input'] : '';
        $model->adversereaction_date = isset($payload['adversereaction_date']) && !empty($payload['adversereaction_date']) ? $payload['adversereaction_date'] : '';
        $model->adversereaction_immediately = isset($payload['adversereaction_immediately']) && !empty($payload['adversereaction_immediately']) ? $payload['adversereaction_immediately'] : '';
        $model->adversereaction_time_input = isset($payload['adversereaction_time_input']) && !empty($payload['adversereaction_time_input']) ? $payload['adversereaction_time_input'] : '';
        $model->adversereaction_degree = isset($payload['adversereaction_degree']) && !empty($payload['adversereaction_degree']) ? $payload['adversereaction_degree'] : '';
        $model->adversereaction_related = isset($payload['adversereaction_related']) && !empty($payload['adversereaction_related']) ? $payload['adversereaction_related'] : '';
        $model->adversereaction_strategy = isset($payload['adversereaction_strategy']) && !empty($payload['adversereaction_strategy']) ? $payload['adversereaction_strategy'] : '';

        $model->tcm_syndrome_type = isset($payload['tcm_syndrome_type']) && !empty($payload['tcm_syndrome_type']) ? $payload['tcm_syndrome_type'] : '';

        $model->pre_degree_pain_chest_ribs = isset($payload['pre_degree_pain_chest_ribs']) && !empty($payload['pre_degree_pain_chest_ribs']) ? $payload['pre_degree_pain_chest_ribs'] : '';
        $model->pre_degree_epigastric_full = isset($payload['pre_degree_epigastric_full']) && !empty($payload['pre_degree_epigastric_full']) ? $payload['pre_degree_epigastric_full'] : '';
        $model->pre_degree_be_upset = isset($payload['pre_degree_be_upset']) && !empty($payload['pre_degree_be_upset']) ? $payload['pre_degree_be_upset'] : '';
        $model->pre_degree_eructation_frequent = isset($payload['pre_degree_eructation_frequent']) && !empty($payload['pre_degree_eructation_frequent']) ? $payload['pre_degree_eructation_frequent'] : '';
        $model->pre_degree_mild_breathing = isset($payload['pre_degree_mild_breathing']) && !empty($payload['pre_degree_mild_breathing']) ? $payload['pre_degree_mild_breathing'] : '';

        $model->pre_frequency_pain_chest_ribs = isset($payload['pre_frequency_pain_chest_ribs']) && !empty($payload['pre_frequency_pain_chest_ribs']) ? $payload['pre_frequency_pain_chest_ribs'] : '';
        $model->pre_frequency_epigastric_full = isset($payload['pre_frequency_epigastric_full']) && !empty($payload['pre_frequency_epigastric_full']) ? $payload['pre_frequency_epigastric_full'] : '';
        $model->pre_frequency_be_upset = isset($payload['pre_frequency_be_upset']) && !empty($payload['pre_frequency_be_upset']) ? $payload['pre_frequency_be_upset'] : '';
        $model->pre_frequency_eructation_frequent = isset($payload['pre_frequency_eructation_frequent']) && !empty($payload['pre_frequency_eructation_frequent']) ? $payload['pre_frequency_eructation_frequent'] : '';
        $model->pre_frequency_mild_breathing = isset($payload['pre_frequency_mild_breathing']) && !empty($payload['pre_frequency_mild_breathing']) ? $payload['pre_frequency_mild_breathing'] : '';

        $model->post_degree_pain_chest_ribs = isset($payload['post_degree_pain_chest_ribs']) && !empty($payload['post_degree_pain_chest_ribs']) ? $payload['post_degree_pain_chest_ribs'] : '';
        $model->post_degree_epigastric_full = isset($payload['post_degree_epigastric_full']) && !empty($payload['post_degree_epigastric_full']) ? $payload['post_degree_epigastric_full'] : '';
        $model->post_degree_be_upset = isset($payload['post_degree_be_upset']) && !empty($payload['post_degree_be_upset']) ? $payload['post_degree_be_upset'] : '';
        $model->post_degree_eructation_frequent = isset($payload['post_degree_eructation_frequent']) && !empty($payload['post_degree_eructation_frequent']) ? $payload['post_degree_eructation_frequent'] : '';
        $model->post_degree_mild_breathing = isset($payload['post_degree_mild_breathing']) && !empty($payload['post_degree_mild_breathing']) ? $payload['post_degree_mild_breathing'] : '';

        $model->post_frequency_pain_chest_ribs = isset($payload['post_frequency_pain_chest_ribs']) && !empty($payload['post_frequency_pain_chest_ribs']) ? $payload['post_frequency_pain_chest_ribs'] : '';
        $model->post_frequency_epigastric_full = isset($payload['post_frequency_epigastric_full']) && !empty($payload['post_frequency_epigastric_full']) ? $payload['post_frequency_epigastric_full'] : '';
        $model->post_frequency_be_upset = isset($payload['post_frequency_be_upset']) && !empty($payload['post_frequency_be_upset']) ? $payload['post_frequency_be_upset'] : '';
        $model->post_frequency_eructation_frequent = isset($payload['post_frequency_eructation_frequent']) && !empty($payload['post_frequency_eructation_frequent']) ? $payload['post_frequency_eructation_frequent'] : '';
        $model->post_frequency_mild_breathing = isset($payload['post_frequency_mild_breathing']) && !empty($payload['post_frequency_mild_breathing']) ? $payload['post_frequency_mild_breathing'] : '';

        $model->status = 0;
        return $model->save();
    }
}
